<template>
  <div class="app-container flex-col minH">
    <div class="topline w100p bgwhite ptb20 radius10 pl10 pr20 justify-between">
      <div>
        <el-input v-model="title" style="width: 280px" placeholder="搜尋標題..." :prefix-icon="Search" class="search" />
        <el-input v-model="concent" style="width: 280px" placeholder="搜尋消息内容..." :prefix-icon="Search" class="search ml10" />

      </div>
      <div>
        <el-button class="btn2" @click="getNoticeList()">查詢</el-button>
        <el-button class="btn1" @click="reset()">重置</el-button>
      </div>
    </div>
    <div class="mt15 radius10 hidden pb15 flex1 bgwhite  flex-col w100p">
      <div class="flex1 w100p ">
        <el-table :data="tableData" style="width: 100%" cell-class-name="tbcell" header-cell-class-name="hdcell">
          <el-table-column prop="title" label="標題" width="300" />
          <el-table-column prop="concent" label="消息内容" min-width="400" />
          <el-table-column prop="created_at" label="創建時間" width="200" sortable />
          <!-- <el-table-column prop="" label="操作" width="240" align="right" fixed="right">
            <template #default>
              <span class=" pointer" @click="edit(2)">展示</span>
              <span class="plr5">|</span>
              <span class=" pointer" @click="edit(2)">編輯</span>
              <span class="plr5">|</span>
              <span class=" pointer red" @click="edit(2)">刪除</span>


            </template>
          </el-table-column> -->
        </el-table>
      </div>

      <div class=" justify-between plr20 w100p mt15">
        <el-button class="btn2" @click="toAdd()">新增</el-button>
        <el-pagination v-model:current-page="currentPage" prev-text="上一頁" next-text="下一頁" :default-page-size="15" :small="small" :disabled="disabled" :background="true" layout="prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </div>

  </div>
</template>

<script setup>
import { Search } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router';
import { noticeList } from '@/api/system.js'
const concent = ref('')
const title = ref('')
onMounted(() => {
  console.log('签到配置页----')
  getNoticeList()
})



const getNoticeList = () => {
  noticeList({
    page: currentPage.value,
    title: title.value,
    concent: concent.value
  }).then((res) => {
    console.log('签到列表', res)
    tableData.value = res.data.data
    total.value = res.data.total
  })
}
const reset = () => {
  title.value = ''
  concent.value = ''
  getNoticeList()
}
const tableData = ref([])
const total = ref(0)
const tableRowClassName = () => {
  return 'tbrow'
}
const currentPage = ref(1)
const handleSizeChange = (val) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`)
  getNoticeList()
}
const router = useRouter()
const toAdd = () => {
  console.log(router)
  router.push({ path: 'addNotice' })
}
const edit = (type) => {
  router.push({ path: 'addNotice' })
}
</script>

<style lang="scss" scoped>
.search {
  overflow: hidden;
  border-radius: 10px !important;
  // padding: 5px 0px;
}
</style>
<style></style>
